<!-- Buttons to add to the header. -->
<core-navbar-buttons end>
    <!-- Select subwiki. -->
    <button ion-button icon-only *ngIf="subwikiData.count > 1" (click)="showSubwikiPicker($event)" [attr.aria-label]="'addon.mod_wiki.subwiki' | translate">
        <ion-icon name="person"></ion-icon>
    </button>

    <button *ngIf="loaded && currentPageObj" ion-button icon-only (click)="openMap($event)"[attr.aria-label]="'addon.mod_wiki.map' | translate" aria-haspopup="true">
        <ion-icon name="map"></ion-icon>
    </button>

    <core-context-menu>
        <core-context-menu-item *ngIf="externalUrl" [priority]="900" [content]="'core.openinbrowser' | translate" [href]="externalUrl" [iconAction]="'open'"></core-context-menu-item>
        <core-context-menu-item *ngIf="description" [priority]="800" [content]="'core.moduleintro' | translate" (action)="expandDescription()" [iconAction]="'arrow-forward'"></core-context-menu-item>
        <core-context-menu-item *ngIf="blog" [priority]="750" content="{{'addon.blog.blog' | translate}}" [iconAction]="'fa-newspaper-o'" (action)="gotoBlog($event)"></core-context-menu-item>
        <core-context-menu-item *ngIf="loaded && !hasOffline && isOnline && !pageIsOffline" [priority]="700" [content]="'core.refresh' | translate" (action)="doRefresh(null, $event)" [iconAction]="refreshIcon" [closeOnClick]="false"></core-context-menu-item>
        <core-context-menu-item *ngIf="loaded && isOnline && (hasOffline || pageIsOffline)"  [priority]="600" [content]="'core.settings.synchronizenow' | translate" (action)="doRefresh(null, $event, true)" [iconAction]="syncIcon" [closeOnClick]="false"></core-context-menu-item>
        <core-context-menu-item *ngIf="canEdit && (isOnline || pageIsOffline)" [priority]="590" [content]="'core.edit' | translate" iconAction="create" (action)="goToEditPage()"></core-context-menu-item>
        <core-context-menu-item *ngIf="canEdit" [priority]="580" [content]="'addon.mod_wiki.createpage' | translate" iconAction="add" (action)="goToNewPage()"></core-context-menu-item>
        <core-context-menu-item *ngIf="prefetchStatusIcon" [priority]="500" [content]="prefetchText" (action)="prefetch($event)" [iconAction]="prefetchStatusIcon" [closeOnClick]="false"></core-context-menu-item>
        <core-context-menu-item *ngIf="size" [priority]="400" [content]="'core.removefiles' | translate:{$a: size}" [iconDescription]="'cube'" (action)="removeFiles()" [iconAction]="'trash'"></core-context-menu-item>
    </core-context-menu>
</core-navbar-buttons>

<!-- Content. -->
<core-loading [hideUntil]="loaded" class="core-loading-center">
    <div padding *ngIf="description || pageIsOffline || hasOffline || pageWarning">
        <core-course-module-description [description]="description" [component]="component" [componentId]="componentId" contextLevel="module" [contextInstanceId]="module.id" [courseId]="courseId"></core-course-module-description>

        <!-- Wiki has something offline. -->
        <div class="core-warning-card" icon-start *ngIf="pageIsOffline || hasOffline">
            <ion-icon name="warning"></ion-icon>
            <span *ngIf="pageIsOffline">{{ 'core.hasdatatosync' | translate:{$a: pageStr} }}</span>
            <span *ngIf="!pageIsOffline">{{ 'core.hasdatatosync' | translate:{$a: moduleName} }}</span>
        </div>

        <!-- Page warning. -->
        <div class="core-warning-card" icon-start *ngIf="pageWarning">
            <ion-icon name="warning"></ion-icon>
            {{ pageWarning }}
        </div>
    </div>
    <div padding class="addon-mod_wiki-page-content">
        <article [ngClass]="{'addon-mod_wiki-noedit': !canEdit}">
            <core-format-text *ngIf="pageContent" [component]="component" [componentId]="componentId" [text]="pageContent" contextLevel="module" [contextInstanceId]="module.id" [courseId]="courseId"></core-format-text>
            <core-empty-box *ngIf="!pageContent" icon="document" [message]="'addon.mod_wiki.nocontent' | translate" [inline]="true"></core-empty-box>
        </article>

        <div margin-top *ngIf="tagsEnabled && currentPageObj && currentPageObj.tags && currentPageObj.tags.length > 0">
            <b>{{ 'core.tag.tags' | translate }}:</b>
            <core-tag-list [tags]="currentPageObj.tags"></core-tag-list>
        </div>
    </div>
</core-loading>

<ion-fab core-fab bottom end *ngIf="canEdit">
    <button ion-fab (click)="goToNewPage()" [attr.aria-label]="'addon.mod_wiki.createpage' | translate">
        <ion-icon name="add"></ion-icon>
    </button>
</ion-fab>
